<template>
    <div>
        <el-form inline :model="query" class="demo-form-inline">
            <el-form-item label="商户名称">
                <el-input v-model="query.user" placeholder="请输入商户名称"></el-input>
            </el-form-item>
            <el-form-item label="帐号类型">
                <el-select v-model="query.region" placeholder="活动区域">
                    <el-option label="全部" value="shanghai"></el-option>
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="handleQuery">查询</el-button>
                <el-button type="success" @click="handleCreate">新建</el-button>
            </el-form-item>
            <el-row>
                <el-form-item>
                    <el-button type="warning">帐号类型管理</el-button>
                </el-form-item>
            </el-row>
        </el-form>
        
        <TablePage ref="tablePage" :fetch="fetchTable" :params="query">
            <el-table-column fixed align="center" type="index" label="序号" width="50"></el-table-column>
            <el-table-column prop="date" align="center" label="商户名称" min-width="250"></el-table-column>
            <el-table-column prop="name" align="center" label="关联活动数量" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="商户状态" width="120"></el-table-column>
            <el-table-column prop="address" align="center" label="最后编辑人" min-width="150"></el-table-column>
            <el-table-column prop="address" align="center" label="创建时间" width="150"></el-table-column>
            <el-table-column align="center" label="操作" width="280">
                <template slot-scope="{row}">
                    <el-button type="text" size="small">可用模版</el-button>
                    <el-button type="text" size="small">查看详情</el-button>
                    <el-button type="text" size="small" @click="handleCreate(row.id)">编辑</el-button>
                    <el-button type="text" size="small">停用</el-button>
                </template>
            </el-table-column>
        </TablePage>
    </div>
</template>
<script>

import TablePage from '@/components/TablePage'
export default {
    components: { TablePage },
    data() {
        return {
            query: {
                user: '',
                region: ''
            }
        }
    },
    methods: {
        fetchTable(pramas) {
            return [
                {   
                    id: 1,
                    date: '2016-05-02',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    id: 2,
                    date: '2016-05-04',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1517 弄'
                }, {
                    id: 3,
                    date: '2016-05-01',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1519 弄'
                }, {
                    id: 4,
                    date: '2016-05-03',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1516 弄'
                }
            ]
        },
        handleQuery() {
            this.fetchTable(this.query);
        },
        handleCreate(id) {
            const _id = id.target ? '' : id;
            this.$router.push({path: '/baseSetting/businessesManage/BusinessesForm', query: { id: (id.target ? '' : id) } });
        }
    }
}
</script>
<style lang="less">

</style>
